package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.PageDomain;
import com.zzyl.nursing.domain.FamilyMember;
import com.zzyl.nursing.dto.DeviceDataDto;
import com.zzyl.nursing.dto.ElderFamilyBindingDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberElderService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.FamilyMemberElderVo;
import com.zzyl.nursing.vo.LoginVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;



    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo vo = familyMemberService.login(dto);
        return success(vo);
    }

    /**
     * 1.1 绑定家人
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ElderFamilyBindingDto dto){
        familyMemberService.FamilyBinding(dto);
        return success();
    }

    /**
     * 1.2 查询家人列表
     * @return
     */
    @GetMapping("/my")
    public AjaxResult my(){
        return success(familyMemberService.FamilyList());
    }

    /**
     * 1.3 查看家人列表（分页查询）
     */
    @GetMapping("/list-by-page")
    public AjaxResult listByPage(PageDomain pageDomain){
        return success(familyMemberService.FamilyListByPage(pageDomain));
    }

    /**
     * 1.4 查询健康数据
     */
    @GetMapping("/queryServiceProperties/{iotId}")
    public AjaxResult queryServicePropertiesByIotId(@PathVariable String iotId){
        return success(familyMemberService.queryServicePropertiesById(iotId));
    }

    /**
     * 1.5  按天统计查询指标数据
     */
    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(DeviceDataDto dto){
        return success(familyMemberService.queryDeviceDataListByDay(dto));
    }

    /**
     * 1.6 按周统计查询指标数据
     */
    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(DeviceDataDto dto){
        return success(familyMemberService.queryDeviceDataListByWeek(dto));
    }



}
